package com.yidu.StockControl.mapper;

import com.yidu.StockControl.entity.CashInventory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;

@Repository
public interface CashInventoryMapper {

    @Select("select * from cashInventory WHERE 1=1 ${strWhere} LIMIT #{page},#{limit}")
    public List<CashInventory> selectCashInventory(Map map);

    @Select("select count(*) from cashInventory")
    int selectCashInventoryCount();

    @Insert("insert into cashInventory values(#{cashInventoryId},#{fundId},#{cashId},#{cashInventoryTime},"+
            "#{businessStatu},#{businessType},#{cashTotalAmount})")
    public int insertCashInventory(CashInventory cashInventory);

    @Update("update cashInventory set cashId =#{cashId}," +
            "fundId=#{fundId},cashInventoryTime=#{cashInventoryTime}," +
            "businessStatu=#{businessStatu},businessType=#{businessType},cashTotalAmount=#{cashTotalAmount} " +
            "where cashInventoryId=#{cashInventoryId}")
    public void  updateCashInventory(CashInventory cashInventory);


    @Delete("delete FROM cashInventory where cashInventoryId = #{cashInventoryId}")
    public void deleteCashInventory(String cashInventoryId);

    @Delete("delete FROM cashInventory where cashInventoryId = #{cashInventoryId} and fundId= #{fundId} and cashInventoryTime = DATE_FORMAT(DATE_ADD(STR_TO_DATE(#{dateTime},'%Y-%m-%d'),INTERVAL -1 DAY),'%Y-%m-%d')")
    public int deleteCashInventoryDate(String cashInventoryId, String fundId, String dateTime);

}
